package com.common.utils;

import java.lang.reflect.InvocationTargetException;

import org.apache.commons.beanutils.PropertyUtilsBean;

import com.google.gson.Gson;

public class JavaBeanUtils {

	private static PropertyUtilsBean pub = new PropertyUtilsBean();
	private static Gson gson = new Gson();
	
	public static void copyProperties(Object dest,Object orig) {
		try {
			pub.copyProperties(dest, orig);
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (InvocationTargetException e) {
			e.printStackTrace();
		} catch (NoSuchMethodException e) {
			e.printStackTrace();
		}
	}
	
	public static String toJson(Object src) {
		String jsonStr = null;
		jsonStr = gson.toJson(src);
		return jsonStr;
	}
}
